<extend name="./public/frame.html"/>
<block name="content">
    <style>
        .layui-form-label{width: 12%;}
        .layui-input-block{margin-left: 12%;}
    </style>
    <form class="layui-form layui-form-pane1" method="post" enctype="multipart/form-data">
        <table class="layui-table">
            <tr>
                <td style="text-align: center;width: 15%">封禁操作</td>
                <td>
                    <input type="radio" name="forbid_type" value="1" title="永久封禁" lay-filter="forbid">
                    <input type="radio" name="forbid_type" value="3" title="暂时封禁" lay-filter="forbid" checked>
                </td>
            </tr>
            <tr>
                <td style="text-align: center;width: 15%">封禁原因</td>
                <td>
                    <input type="text" required lay-verify="required" name="forbid_content" id="forbid_content" value="" class="layui-input" placeholder="封禁原因">
                </td>
            </tr>
            <tr class="forbid_time">
                <td style="text-align: center;">解禁日期</td>
                <td>
                    <input type="text" class="layui-input date" readonly id="forbid_time_end" name="forbid_time_end" placeholder="解禁日期">
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <input type="hidden" value="<?php echo $driver_id;?>" name="driver_id" id="driver_id">
                    <input type="hidden" value="forbid" name="act" id="act">
                    <button class="layui-btn" lay-submit lay-filter="*">提交封禁</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </td>
            </tr>
        </table>
    </form>
    <script>
        layui.use(['form','laydate'], function () {
            var form = layui.form, laydate = layui.laydate;
            laydate.render({
                elem: '.date'
                ,type: 'datetime'
                ,trigger: 'click'
            });
            form.on('radio(forbid)', function(data){
                if(data.value == 1){
                    $(".forbid_time").css('display','none');
                }else{
                    $(".forbid_time").css('display','');
                }
            });
            form.on('submit(*)', function(data){
                $.ajax({
                    url:'{:url("/admin/driver/ajax_forbid")}',
                    async:true,
                    dataType:'json',
                    type:'POST',
                    data: $(data.form).serialize(),
                    success:function(res){
                        if(res.code==1){
                            layer.alert(res.msg, {icon: 6},function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                window.parent.location.reload()
                            });
                        }else{
                            layer.msg(res.msg,{icon: 5});
                        }
                    }
                });
                return false;
            });
        });
    </script>
</block>
